package logic

import (
	"baidutieba/models/mysql"
	"context"

	"baidutieba/tiebarpc/internal/svc"
	"baidutieba/tiebarpc/tiebarpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type TieBaShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewTieBaShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *TieBaShowLogic {
	return &TieBaShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *TieBaShowLogic) TieBaShow(in *tiebarpc.TieBaShowRequest) (*tiebarpc.TieBaShowResponse, error) {
	// todo: add your logic here and delete this line

	var tieba mysql.TieBa
	mysql.DB.Where("id =?", in.Id).Find(&tieba)
	return &tiebarpc.TieBaShowResponse{
		Title:   tieba.Title,
		Image:   tieba.Image,
		Num:     tieba.Num,
		UserId:  tieba.UserId,
		Context: tieba.Context,
		Class:   tieba.Class,
	}, nil
}
